/*خروج خودکار کاربر*/

/*پس از خروج از حساب کاربری، کاربر به صفحه اصلی سایت هدایت می‌شود*/
function skip_logout_confirmation() {
    global $wp;
    if ( isset( $wp->query_vars['customer-logout'] ) ) {
        wp_redirect( str_replace( '&amp;', '&', wp_logout_url( home_url() ) ) );
        exit;
    }
}
add_action( 'template_redirect', 'skip_logout_confirmation' );

/*پس از خروج از حساب کاربری، کاربر به صفحه حساب کاربری هدایت می‌شود*/
function wc_bypass_logout_confirmation() {
    global $wp;
 
    if ( isset( $wp->query_vars['customer-logout'] ) ) {
        wp_redirect( str_replace( '&amp;', '&', wp_logout_url( wc_get_page_permalink( 'myaccount' ) ) ) );
        exit;
    }
}
 
add_action( 'template_redirect', 'wc_bypass_logout_confirmation' );

/*لینک*/
dm.tst/my-account/customer-logout/
